home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / guile / 1.8 / ice-9 / stack-catch.scm < prev    next >
Encoding:
Text File  |  2008-12-17  |  1.8 KB  |  44 lines

  1. ;;; installed-scm-file
  2.  
  3. ;;;;     Copyright (C) 2001, 2006 Free Software Foundation, Inc.
  4. ;;;; 
  5. ;;;; This library is free software; you can redistribute it and/or
  6. ;;;; modify it under the terms of the GNU Lesser General Public
  7. ;;;; License as published by the Free Software Foundation; either
  8. ;;;; version 2.1 of the License, or (at your option) any later version.
  9. ;;;; 
  10. ;;;; This library is distributed in the hope that it will be useful,
  11. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ;;;; Lesser General Public License for more details.
  14. ;;;; 
  15. ;;;; You should have received a copy of the GNU Lesser General Public
  16. ;;;; License along with this library; if not, write to the Free Software
  17. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. ;;;; 
  19.  
  20. (define-module (ice-9 stack-catch)
  21.   :export (stack-catch))
  22.  
  23. (define (stack-catch key thunk handler)
  24.   "Like @code{catch}, invoke @var{thunk} in the dynamic context of
  25. @var{handler} for exceptions matching @var{key}, but also save the
  26. current stack state in the @var{the-last-stack} fluid, for the purpose
  27. of debugging or re-throwing of an error.  If thunk throws to the
  28. symbol @var{key}, then @var{handler} is invoked this way:\n
  29. @example
  30.  (handler key args ...)
  31. @end example\n
  32. @var{key} is a symbol or #t.\n
  33. @var{thunk} takes no arguments.  If @var{thunk} returns normally, that
  34. is the return value of @code{catch}.\n
  35. Handler is invoked outside the scope of its own @code{catch}.  If
  36. @var{handler} again throws to the same key, a new handler from further
  37. up the call chain is invoked.\n
  38. If the key is @code{#t}, then a throw to @emph{any} symbol will match
  39. this call to @code{catch}."
  40.   (catch key
  41.      thunk
  42.      handler
  43.      lazy-handler-dispatch))
  44.